﻿package com.d4p.custom.defaultButton
{
	import com.d4p.util.MouseMove;
	import flash.events.MouseEvent;
	
	public class DefaultOverBtn extends MouseMove
	{
		private static const OVER:String 	= "over";
		private static const OUT:String  	= "out";
		private static const CLICK:String 	= "click";
		
		public function DefaultOverBtn()
		{
			super();
			this.buttonMode = true;
			this.mouseChildren =false; 
			this.stop();
			this.addEvent();
		}
		protected function addEvent():void
		{
			this.addEventListener(MouseEvent.ROLL_OVER, onMouseOverHandler);
		}
		protected function removeEvent():void
		{
			this.removeEventListener(MouseEvent.ROLL_OUT, onMouseOutHandler);
			this.removeEventListener(MouseEvent.ROLL_OVER, onMouseOutHandler);
		}
		
		
		protected function onMouseOverHandler(e:MouseEvent):void
		{
			playFrame(OVER);
			this.addEventListener(MouseEvent.ROLL_OUT, onMouseOutHandler);
		}
		protected function onMouseOutHandler(e:MouseEvent):void
		{
			playFrame(OUT);
			this.removeEventListener(MouseEvent.ROLL_OUT, onMouseOutHandler);
		}
		
		protected function playClick():void
		{
			this.mouseChildren =false;
			this.mouseEnabled = false;
			playFrame(CLICK);
			this.removeEventListener(MouseEvent.ROLL_OUT, onMouseOutHandler);
			this.removeEventListener(MouseEvent.ROLL_OVER, onMouseOutHandler);
			
		}
		
		protected function playReset():void
		{
			this.mouseChildren= true;
			this.mouseEnabled = true;
			playFrame(OUT);
			if(this.hasEventListener("rollOver")==false){
				this.addEventListener(MouseEvent.ROLL_OVER, onMouseOverHandler);
			}
		}
		
		
	}
}